package cn.dianhun.om.jpa.vuecontroller;

import cn.dianhun.om.jpa.pojo.SysUserRoleEntity;
import cn.dianhun.om.jpa.repository.UserRoleRepository;
import cn.dianhun.om.jpa.utills.ResultVO;
import cn.dianhun.om.jpa.utills.ResultVOUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.HashMap;
import java.util.List;

/**
 * @author cyt
 * @create 2020-07-13 13:48
 */
@CrossOrigin
@RequestMapping("/api")
@RestController
public class TestController {
    @Autowired
    private UserRoleRepository userRoleRepository;

    /**
     * 测试联调
     *
     * @return
     */
    @GetMapping("/user/info")
    public ResultVO<HashMap> getInfo() {
        HashMap<Object, Object> map = new HashMap<>();
        map.put("roles", "admin");
        map.put("introduction", "I am a superadministrator");
        map.put("avatar", "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("name", "Super Admin");
        return ResultVOUtil.successWith(map);
    }

    @PostMapping("/user/login")
    public ResultVO<List<SysUserRoleEntity>> login() {
        List<SysUserRoleEntity> userRoleRepositoryAll = userRoleRepository.findAll();
        return ResultVOUtil.successWith(userRoleRepositoryAll);
    }
}
